<?php
namespace Mobile\Controller;
use Think\Controller\RestController;
class PublicController extends RestController{
	 function list(){
    	$maxOb = M("Maxlist");
    	$tarr = $maxOb->where("id<6")->select();
    	$darr = $maxOb->where("id>5")->select();
    	$this->assign('tarr',$tarr);
    	$this->assign('darr',$darr);
    }
    function tit(){
    	$cname=CONTROLLER_NAME;
	   	$baojiaOb = M("Maxlist");
	   	$map['action']=array('like',"%$cname%");
	   	$tit = $baojiaOb->where($map)->find();
	   	$this->assign('tit',$tit);
    }
    function getip(){
//        $clientIP=get_client_ip();
//        $taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$clientIP;
//        $IPinfo = json_decode(file_get_contents($taobaoIP));
//        $province = $IPinfo->data->region;
//        $city = $IPinfo->data->city;
//        $data = $city;
//        $this->assign('data',$data);
//        import('ORG.Net.IpLocation');// 导入IpLocation类
            $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
            preg_match("#http://(.*?)\.#i ",$url,$match);
            if($match[1]==www){
                $Ip = new \Org\Net\IpLocation('qqwry.dat');
                $ip = '123.149.4.222';//get_client_ip();
                $arr = $Ip->getlocation($ip);

                $country = $arr["country"];
                $city = iconv("GB2312","UTF-8",$country);
                $arr = explode(省,$city);
                $data=$arr["1"];
            }else{
                $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
                preg_match("#http://(.*?)\.#i ",$url,$match);
                $cityOb = M("City");
                $arr = $cityOb->where("pinyin='$match[1]'")->find();
                $data = $arr['name'];
            }
        //$py = new \Org\Util\Pinyin;
       // $data = $py->qupinyin($city);
        $this->assign('data',$data);
    }
    // function layout(){
    //    session_start();
    //   if(isset($_SESSION['username'])){
    //        // session_unset();//free all session variable
    //         session_destroy();//销毁一个会话中的全部数据
    //         echo "<script>alert('退出成功');parent.location.href='index';</script>";
    //     }else{
    //       echo "<script>alert('退出失败');parent.location.href='index';</script>";
    //     }
    // }
    function zhuanpy(){
        $py = new \Org\Util\Pinyin;

        echo $py->qupinyin('汉字');
       // --- hanzi
        echo $py->qupinyin('汉字',true);
        //--- hz
        echo $py->qupinyin('汉####字',true);
       // --- h____z
        echo $py->qupinyin('汉####字',true,'/');
       // --- h////z
    }
}